package com.itheima.dao;

import org.apache.ibatis.annotations.*;
import org.example.Users;
import org.example.Users2;

import java.util.List;

public interface UsersMapper {
    @Select("select * from users")
    List<Users> AllUsers();

    @Select("select * from users where id = #{id}")
    Users findUsersById(int id);

    @Insert("insert into users(name,age) value(#{name},#{age})")
    int insertUsers(Users u);

    @Delete("delete from users where id = #{id}")
    int deleteUsers(int id);

    @Update("update users set name = #{name},agr = #{age} where id = #{id}")
    int updateUsers(Users u);

    @Select("select * from users where id = #{id}")
    @Results({@Result(property = "ordersList",column = "id"
            ,many = @Many(select = "com.itheima.dao.OrdersMapper.selectOrders"))})
    Users2 selectUsers2(int id);

}
